import javax.media.opengl.GL2;


/**
 * Defines a generic object
 * Created 27/apr/2013.
 * * @author Pietro Bolognesi matr. 227383
 * @author Giorgio Lazzaretti matr. 220232.
 *        
 */
public class GenericGlObject extends Object {
	/**
	 * contains the type of object that can be created
	 *
	 *NONE
	 *SPHERE
	 *CUBE
	 *CYLINDER
	 *
	 *   @author Pietro Bolognesi matr. 227383
	 * @author Giorgio Lazzaretti matr. 220232
	 *      
	 */
	public enum OBJType {
	    /**
	     * Identifies a generic object.
	     */
	    NONE, /**
	     * Identifies a sphere.
	     */
	    SPHERE , /**
	     * Identifies a cube.
	     */
	    CUBE, /**
	     * Identifies a cylinder.
	     */
	    CYLINDER
	}

	/**
	 * OpenGL content.
	 */
	protected GL2 gl;
	private float XPos, YPos, ZPos;
	/**
	 * Color component RED.
	 */
protected float Red = 1.0f;
	/**
	 * Color component GREEN.
	 */
	protected float Green = 0.0f;
	/**
	 * Color component BLUE.
	 */
	protected float Blue = 0.0f;
	/**
	 * Id of the object.
	 */
	protected int Id;
	/**
	 * Set if the object is drawable in the next draw cycle.
	 */
	protected boolean ToDraw = true;
    
	/**
	 * Contains the name of the object.
	 */
	public String ObjectName = "Object";
	/**
	 * Contains the type of the object.
	 */
	public OBJType type = OBJType.NONE;
	
	//Setter e getter delle variabile private
	/**
	 * Return the x coord. of the object.
	 *
	 * @return x coordinate.
	 */
	public float GetXPos(){ return this.XPos;}
	/**
	 * Return the y coord. of the object.
	 * @return y coordinate.
	 */
	public float GetYPos(){ return this.YPos;}
	/**
	 * Return the z coord. of the object.
	 *
	 * @return z coordinate.
	 */
	public float GetZPos(){ return this.ZPos;}
	/**
	 * Set the position if the object.
	 * @param x x coordinate.
	 * @param y y coordinate.
	 * @param z z coordinate.
	 */
	public void SetPos(float x, float y, float z){
		this.XPos = x; this.YPos = y; this.ZPos = z;
	}
	
	/**
	 * Set the color of the object.
	 *
	 * @param r Color red component.
	 * @param g Color green component.
	 * @param b Color blue component.
	 */
	public void SetObjectColor(float r, float g, float b){
		this.Red = (r <= 1)? ((r >= 0)? r : 0) : 1;
		this.Green = (g <= 1)? ((g >= 0)? g : 0) : 1;
		this.Blue = (b <= 1)? ((b >= 0)? b : 0) : 1;
	}
	
	/**
	 * returns the color red component.
	 *
	 * @return Red component.
	 */
	public float GetRedComponent(){ return this.Red;}
	/**
	 *  returns the color green component.
	 *
	 * @return Green component.
	 */
	public float GetGreenComponent(){ return this.Green;}
	/**
	 *  returns the color blue component.
	 *
	 * @return Blue component.
	 */
	public float GetBlueComponent(){ return this.Blue;}
	
	/**
	 * Assign the gl content of the world to the object gl.
	 *
	 * @param newgl takes the world gl.
	 */
	public void SetGL(GL2 newgl){ this.gl = newgl;}
	/**
	 * Returns the gl that has been assigned to the object.
	 *
	 * @return Gl
	 */
	public GL2 GetGL(){return this.gl;}
	
	/**
	 * Get the object Id.
	 *
	 * @return Id
	 */
	public int GetId(){return this.Id;}
	/**
	 * Set the object Id.
	 *
	 * @param newId the Id of the object to set.
	 */
	public void SetId(int newId){this.Id = newId;}
	
	/**
	 * Returns true if the object is drawable.
	 *
	 * @return IsToDraw
	 */
	public boolean IsToDraw(){return this.ToDraw;}
	/**
	 * Defines if the object has to be draw in the world rendering.
	 *
	 * @param toDraw If this is true the object is drawable.
	 */
	public void SetDraw(boolean toDraw){this.ToDraw = toDraw;}
	
	/**
	 * draws a generic object. overrided in all the estended classes.
	 *
	 */
	public void DrawObject() {
		//TODO overrided
	}
}
